package prettypenny;

import java.sql.*;
import java.util.*;
import java.text.*;
public class AddBooking extends javax.swing.JFrame {
    private Lists clients;
    private BookingList bookings;
    private Booking currBooking;
    private CarList cars;
    private Client newClient;
    private Connection con;
    private Statement stmt;
    private ResultSet rs;
    public AddBooking(BookingList bookings, Lists clients) {
        initComponents();
        this.bookings = bookings;
        this.clients = clients;
        try { 
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // server:port:database
            con = DriverManager.getConnection("jdbc:odbc:uni");
            stmt = con.createStatement(); 

        } catch(Exception ex) {
            System.out.println(ex.toString());
        } 
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel20 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        forenameBox = new javax.swing.JTextField();
        customerDOB = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        customerMobile = new javax.swing.JTextField();
        customerEmail = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        customerAdd = new javax.swing.JTextField();
        customerAdd1 = new javax.swing.JTextField();
        customerCity = new javax.swing.JTextField();
        customerCounty = new javax.swing.JTextField();
        customerPostcode = new javax.swing.JTextField();
        customerHomeNumber = new javax.swing.JTextField();
        customerID = new javax.swing.JTextField();
        addButt = new javax.swing.JButton();
        clrButton = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        carID = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        mileage = new javax.swing.JTextField();
        notes = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        date = new javax.swing.JTextField();
        time = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        type = new javax.swing.JTextField();
        surnameBox = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        locationID = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        price = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        duration = new javax.swing.JTextField();

        jLabel20.setText("jLabel20");
        jLabel20.setName("jLabel20"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel6.setText("Customer Name");
        jLabel6.setName("jLabel6"); // NOI18N

        forenameBox.setText("clientName");
        forenameBox.setName("forenameBox"); // NOI18N

        customerDOB.setText("26/07/94");
        customerDOB.setName("customerDOB"); // NOI18N

        jLabel7.setText("DoB");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText("Mobile");
        jLabel8.setName("jLabel8"); // NOI18N

        customerMobile.setText("07948919");
        customerMobile.setName("customerMobile"); // NOI18N

        customerEmail.setText("clientName");
        customerEmail.setName("customerEmail"); // NOI18N

        jLabel9.setText("Email");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel1.setText("Address");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("ID");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("City");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText("County");
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText("Postcode");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel10.setText("Home Number");
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel13.setText("Address 2");
        jLabel13.setName("jLabel13"); // NOI18N

        customerAdd.setText("clientName");
        customerAdd.setName("customerAdd"); // NOI18N

        customerAdd1.setText("clientName");
        customerAdd1.setName("customerAdd1"); // NOI18N

        customerCity.setText("clientName");
        customerCity.setName("customerCity"); // NOI18N

        customerCounty.setText("clientName");
        customerCounty.setName("customerCounty"); // NOI18N

        customerPostcode.setText("gf45rg");
        customerPostcode.setName("customerPostcode"); // NOI18N

        customerHomeNumber.setText("0751919819");
        customerHomeNumber.setName("customerHomeNumber"); // NOI18N

        customerID.setEditable(false);
        customerID.setText("clientName");
        customerID.setEnabled(false);
        customerID.setName("customerID"); // NOI18N

        addButt.setText("Add");
        addButt.setName("addButt"); // NOI18N
        addButt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtActionPerformed(evt);
            }
        });

        clrButton.setText("Clear");
        clrButton.setName("clrButton"); // NOI18N

        jLabel12.setText("maybe add table of curr clients..make this overall client form");
        jLabel12.setName("jLabel12"); // NOI18N

        jLabel14.setText("Car");
        jLabel14.setName("jLabel14"); // NOI18N

        carID.setText("5");
        carID.setName("carID"); // NOI18N
        carID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carIDActionPerformed(evt);
            }
        });

        jLabel15.setText("Mileage");
        jLabel15.setName("jLabel15"); // NOI18N

        mileage.setText("100");
        mileage.setName("mileage"); // NOI18N
        mileage.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                mileagePropertyChange(evt);
            }
        });

        notes.setText("notes");
        notes.setName("notes"); // NOI18N

        jLabel16.setText("Notes");
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setText("Date");
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setText("Time");
        jLabel18.setName("jLabel18"); // NOI18N

        date.setText("10/04/10");
        date.setName("date"); // NOI18N

        time.setText("13");
        time.setName("time"); // NOI18N

        jLabel19.setText("Type");
        jLabel19.setName("jLabel19"); // NOI18N

        type.setText("1");
        type.setName("type"); // NOI18N

        surnameBox.setText("jTextField1");
        surnameBox.setName("surnameBox"); // NOI18N

        jLabel21.setText("Location");
        jLabel21.setName("jLabel21"); // NOI18N

        locationID.setText("1");
        locationID.setName("locationID"); // NOI18N

        jLabel22.setText("Price");
        jLabel22.setName("jLabel22"); // NOI18N

        price.setText("3");
        price.setName("price"); // NOI18N

        jLabel23.setText("Duration");
        jLabel23.setName("jLabel23"); // NOI18N

        duration.setText("2");
        duration.setName("duration"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jLabel12))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(83, 83, 83)
                                .addComponent(customerID, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(27, 27, 27)
                                .addComponent(customerHomeNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(50, 50, 50)
                                .addComponent(customerPostcode, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(59, 59, 59)
                                .addComponent(customerCounty, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(75, 75, 75)
                                .addComponent(customerCity, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addGap(46, 46, 46)
                                .addComponent(customerAdd1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(55, 55, 55)
                                .addComponent(customerAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(18, 18, 18)
                                .addComponent(forenameBox, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(surnameBox, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(75, 75, 75)
                                .addComponent(customerDOB, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addGap(64, 64, 64)
                                .addComponent(customerMobile, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addGap(70, 70, 70)
                                .addComponent(customerEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)))
                        .addGap(64, 64, 64)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(jLabel17)
                            .addComponent(jLabel19)
                            .addComponent(jLabel22)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel21)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel15)
                                            .addComponent(jLabel14)
                                            .addComponent(jLabel16))
                                        .addGap(28, 28, 28)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(carID, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(mileage, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
                                            .addComponent(notes, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(locationID, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(price, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(77, 77, 77)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(addButt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(clrButton)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel23)
                                .addGap(24, 24, 24)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(duration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(addButt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(clrButton))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(customerID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(forenameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(surnameBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(customerDOB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(customerMobile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(customerEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(customerAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(customerAdd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(customerCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(customerCounty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(customerPostcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(customerHomeNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(88, 88, 88)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel21)
                                    .addComponent(locationID)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel14)
                                    .addComponent(carID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel15)
                                    .addComponent(mileage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel16)
                                    .addComponent(notes))
                                .addGap(32, 32, 32)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(price, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(duration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23))))
                .addGap(117, 117, 117)
                .addComponent(jLabel12)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void mileagePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_mileagePropertyChange
}//GEN-LAST:event_mileagePropertyChange



private void addClient(Client newClient) {
        try{
            Statement insertStmt = con.createStatement();
            String insertSql = "insert into client (clientId, forename, surname, dob, addLine1, addLine2, city, county, postcode, homeNum, mobileNum, email) values('"+
                    newClient.getID() +"', '"+
                    newClient.getForename()+"', '"+
                    newClient.getSurname()+"', '"+
                    newClient.getDoB()+"', '"+
                    newClient.getAdd1()+"', '"+ newClient.getAdd2()+"', '"+ newClient.getCity()+"', '"+
                            newClient.getCounty()+"', '"+
                            newClient.getPostCode()+"', '"+
                            newClient.getHomeNum()+"', '"+
                            newClient.getMobile()+"', '"+
                            newClient.getEmail()+"')";
            System.out.println(insertSql);
            insertStmt.executeUpdate(insertSql);
            clients.RefreshData();
        }
        catch (SQLException ex){
            System.out.println(ex.toString());
        }
}
/* DB Struture
     * car: carId, make, model, fuelType, regNum
    
     * client: clientId, forname, surname, dob, addLine1, addLine2, city, county, postcode, homeNum, mobileNum, email
     * location: locationId, branch
     * mechanic: mechanicId, forename, surname, mobNum
     * serviceType: typeId, typeOfService
     *carService: serviceID, clientId, carId, locationId, mechanicId, typeId, serviceDate, serviceTime, description, price, bookingDate, mileage
*/
private void addBooking(Booking newBooking) {
           try{
            Statement insertStmt = con.createStatement();
            String insertSql = "insert into carService (serviceID, clientId, carId, locationId, mechanicId, typeId, serviceDate, serviceTime, serviceDurationHour, description, price, bookingDate, mileage) values('"+
                    newBooking.getServiceID()+"', '"+
                    newBooking.getClientID()+"', '"+
                    newBooking.getCarID()+"', '"+ newClient.getAdd2()+"', '"+ newClient.getCity()+"', '"+
                    newBooking.getLocationID()+"', '"+
                    newBooking.getMechanicID()+"', '"+
                    newBooking.getType()+"', '"+
                    newBooking.getServiceDate()+"', '"+
                    newBooking.getServiceTime()+"', '"+
                    newBooking.getDuration()+"', '"+
                    newBooking.getServiceDesc()+"', '"+
                    newBooking.getPrice()+"', '"+
                    newBooking.getBookingDate()+"', '"+
                    newBooking.getMileage()+"')";
            System.out.println(insertSql);
            insertStmt.executeUpdate(insertSql);
            bookings.RefreshData();
        }
        catch (SQLException ex){
            System.out.println(ex.toString());
        }
}

private void addButtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtActionPerformed
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    java.util.Date dates = new java.util.Date();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yy");
    SimpleDateFormat formatter2 = new SimpleDateFormat("dd/mm/yyyy");
    String testDate = date.getText();
    try {
       Client newClient = new Client( // add here, carry over the list
                clients.getClientSize()+3, // TODO CHECK THIS
                forenameBox.getText(),
                surnameBox.getText(),
                formatter2.format(formatter.parse(customerDOB.getText())), // CHECK
                //customerDOB.getText(),
                customerAdd.getText(),
                customerAdd1.getName(),
                customerCity.getText(),
                customerCounty.getText(),
                customerPostcode.getText(),
                customerHomeNumber.getText(),
                customerMobile.getText(),
                customerEmail.getText());
        addClient(newClient);

        Booking newBooking = new Booking (
                bookings.getSize(),
                newClient.getID(),
                Integer.parseInt(carID.getText()),
                Integer.parseInt(locationID.getText()),
                1, // TODO MECHANIC IDS - auto assign - prolly wont have time
                Integer.parseInt(type.getText()),
                formatter2.format(formatter.parse(date.getText())), // CHECK
                time.getText(),
                Integer.parseInt(duration.getText()),
                notes.getText(),
                Double.parseDouble(price.getText()), // date.setText(formatter2.format(formatter.parse(testDate)))
                dateFormat.format(dates),
                Integer.parseInt(mileage.getText())        
                );
    } catch(Exception ex) {
        System.out.println(ex.toString());
        
    }

}//GEN-LAST:event_addButtActionPerformed

private void carIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carIDActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_carIDActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AddBooking.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AddBooking.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AddBooking.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AddBooking.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                //new AddBooking().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButt;
    private javax.swing.JTextField carID;
    private javax.swing.JButton clrButton;
    private javax.swing.JTextField customerAdd;
    private javax.swing.JTextField customerAdd1;
    private javax.swing.JTextField customerCity;
    private javax.swing.JTextField customerCounty;
    private javax.swing.JTextField customerDOB;
    private javax.swing.JTextField customerEmail;
    private javax.swing.JTextField customerHomeNumber;
    private javax.swing.JTextField customerID;
    private javax.swing.JTextField customerMobile;
    private javax.swing.JTextField customerPostcode;
    private javax.swing.JTextField date;
    private javax.swing.JTextField duration;
    private javax.swing.JTextField forenameBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField locationID;
    private javax.swing.JTextField mileage;
    private javax.swing.JTextField notes;
    private javax.swing.JTextField price;
    private javax.swing.JTextField surnameBox;
    private javax.swing.JTextField time;
    private javax.swing.JTextField type;
    // End of variables declaration//GEN-END:variables
}
